package com.zhentao.schedule.controller;

import com.zhentao.model.schedule.dto.TaskDto;
import com.zhentao.schedule.model.common.dtos.ResponseResult;
import com.zhentao.schedule.service.TaskInfoService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/task")
public class ScheduleController {
    @Resource
    TaskInfoService taskInfoService;
    @PostMapping("/add")
    public ResponseResult addTask(@RequestBody TaskDto taskDto){
      return ResponseResult.okResult(taskInfoService.addTask(taskDto));
    }


    //按照类型和优先级来拉取任务
    @GetMapping("/poll/{type}/{priority}")
    public ResponseResult poll(@PathVariable("type") int type, @PathVariable("priority")  int priority){
        return ResponseResult.okResult(taskInfoService.poll(type,priority));
    }
}
